home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / language / embedded / develop / libsrc11.arc / XGBLKSPI.C < prev    next >
C/C++ Source or Header  |  1989-04-27  |  1KB  |  41 lines

  1. /*    xgblkspi.c 4.3        */
  2. /*F****************************************************************************
  3.  
  4. FUNCTION NAME:    xgblkspi
  5.  
  6. ACTION:        Reads/writes count characters from/to the SPI port
  7.         to/from an array of bytes (unsigned short).
  8.  
  9. PARAMETERS:
  10.         array:    pointer to an array of bytes.  This array is
  11.             first read from to get a byte to output, then
  12.             the same location is written with the byte
  13.             input from the port.
  14.  
  15.         count:    number of bytes to be read/written.
  16.  
  17. RETURNS:    (void)
  18.  
  19. ******************************************************************************/
  20.  
  21. #include <hc11/directives.h>
  22.  
  23. SMALL
  24. void xgblkspi(array, count)
  25.  
  26.     unsigned short    *array;        /* pointer to data to be read/written */
  27.     int        count;        /* number of bytes to be read/written */
  28.  
  29.     {
  30.  
  31.     /****************************************************************/
  32.     /*    Note that "while ((count--) > 0)" is equivalent to    */
  33.     /*    "while ((--count) >= 0)" but the pre-decrement version    */
  34.     /*    is more efficient than the post-decrement version.    */
  35.     /****************************************************************/
  36.  
  37.     while ((--count) >= 0)
  38.         *(array++) = xgbytspi((unsigned) *(array));
  39.  
  40.     }    /* end of xgblkspi    */
  41.